<template>
  <div class="bread-crumb">
    <el-breadcrumb separator="/">
      <el-breadcrumb-item v-show="!isIndex" :to="{ path: '/' }">
        首页
      </el-breadcrumb-item>
      <el-breadcrumb-item v-for="item in breadList" :key="item.path">
        {{ item.meta.title }}
      </el-breadcrumb-item>
    </el-breadcrumb>
  </div>
</template>

<script>
export default {
  computed: {
    breadList() {
      return this.$route.matched.filter(item => {
        if (item.meta && item.meta.title) return item
      })
    },

    isIndex() {
      let indexPath = ['/', '/dashboard']
      return this.breadList.some(item => {
        return indexPath.includes(item.path)
      })
    }
  }
}
</script>

<style lang="scss" scoped>
:deep().el-breadcrumb__item {
  font-size: 12px !important;
}
.bread-crumb {
  margin-left: 10px;
}
</style>
